# -*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name:        logger.py
# Purpose:
#
# Author:      Drago@
#
# Created:     08.08.2009
# Copyright:   (c) Drago@ 2009
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python

from datetime import datetime

class Logger(object):
    """
        Logger class
    """

    writeToFile = True
    writeToScreen = True
    logFile = None

    def __init__(self):
        self.logFile = open("c:\\pygs_log.txt", "wa")

    def __del__(self):
        self.logFile.close()

    def log(self, message):
        message = "%s\tINFO\t%s\n" % (datetime.now(), message)
        if self.writeToScreen:
            print message
        if self.writeToFile:
            self.logFile.write(message)
            self.logFile.flush()

    def debug(self, message):
        message = "%s\tDEBUG\t%s\n" % (datetime.now(), message)
        if self.writeToScreen:
            print message
        if self.writeToFile:
            self.logFile.write(message)
            self.logFile.flush()

logger = Logger()